import request from '@/utils/request'
import requestFile from '@/utils/request-file'
import { formatDateByFmt } from '@/utils/util'
import qs from 'qs'

const prefixUrl = 'web/work_submit'

// 获取每个状态的数量
export function status_count(params) {
  return request({
    url: prefixUrl + '/status_count',
    method: 'get',
    params
  })
}

// 获取列表
export function check_list(data) {
  return request({
    url: prefixUrl + '/check_list',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 获取工单下拉项
export function worker_order_list(params) {
  return request({
    url: prefixUrl + '/worker_order_list',
    method: 'get',
    params
  })
}

// 获取楼盘和媒体类型下拉项
export function new_install_building_list_and_media_type(params) {
  return request({
    url: prefixUrl + '/new_install_building_list_and_media_type',
    method: 'get',
    params
  })
}

// 通过
export function pass(data) {
  return request({
    url: prefixUrl + '/pass',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 不通过
export function no_pass(data) {
  return request({
    url: prefixUrl + '/no_pass',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 撤销不通过
export function revoke(data) {
  return request({
    url: prefixUrl + '/revoke',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 删除
export function remove(data) {
  return request({
    url: prefixUrl + '/delete',
    method: 'post',
    content_type: 'json',
    data
  })
}

// 安装统计
export function page(params) {
  return request({
    url: prefixUrl + '/page',
    method: 'get',
    params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}

// 安装导出
export function exportExcel(params) {
  return requestFile({
    url: prefixUrl + '/exportExcel',
    method: 'get',
    params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    },
    fileName: '安装导出' + (formatDateByFmt(new Date(), 'yyyyMMddhhmmss') + Math.floor(Math.random() * (
      1000000 -
      1) + 1)) + '.xls'
  })
}

// 安装上画明细列表
export function installCountRecord(params) {
  return request({
    url: prefixUrl + '/installCountRecord',
    method: 'get',
    params
  })
}

// 安装数量统计列表
export function installCountPage(params) {
  return request({
    url: prefixUrl + '/installCountPage',
    method: 'get',
    params
  })
}

// 替换图片
export function replacePhoto(params) {
  return request({
    url: prefixUrl + '/replacePhoto',
    method: 'post',
    params
  })
}

// 删除图片
export function removePhoto(params) {
  return request({
    url: prefixUrl + '/removePhoto',
    method: 'delete',
    params
  })
}


